package com.ruoyi.system.service.impl;

import java.util.List;
import com.ruoyi.common.utils.DateUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.system.mapper.T3rdstockMapper;
import com.ruoyi.system.domain.T3rdstock;
import com.ruoyi.system.service.IT3rdstockService;

/**
 * 第三方库存信息Service业务层处理
 * 
 * @author ruoyi
 * @date 2024-05-15
 */
@Service
public class T3rdstockServiceImpl implements IT3rdstockService 
{
    @Autowired
    private T3rdstockMapper t3rdstockMapper;

    /**
     * 查询第三方库存信息
     * 
     * @param warehouseId 第三方库存信息主键
     * @return 第三方库存信息
     */
    @Override
    public T3rdstock selectT3rdstockByWarehouseId(String warehouseId)
    {
        return t3rdstockMapper.selectT3rdstockByWarehouseId(warehouseId);
    }

    /**
     * 查询商品库存
     *
     * @param t3rdstock 第三方库存信息主键
     * @return 第三方库存信息
     */
    @Override
    public T3rdstock selectGoodsStockFromT3rdstock(T3rdstock t3rdstock)
    {
        return t3rdstockMapper.selectGoodsStockFromT3rdstock(t3rdstock);
    }

    /**
     * 查询第三方库存信息列表
     * 
     * @param t3rdstock 第三方库存信息
     * @return 第三方库存信息
     */
    @Override
    public List<T3rdstock> selectT3rdstockList(T3rdstock t3rdstock)
    {
        return t3rdstockMapper.selectT3rdstockList(t3rdstock);
    }

    /**
     * 通过商品id与仓库id查询第三方库存信息列表
     *
     * @param t3rdstock 第三方库存信息
     * @return 第三方库存信息
     */
    @Override
    public List<T3rdstock> selectT3rdstockByGoodIdAndWarehouseId(T3rdstock t3rdstock)
    {
        return t3rdstockMapper.selectT3rdstockByGoodIdAndWarehouseId(t3rdstock);
    }

    /**
     * 新增第三方库存信息
     * 
     * @param t3rdstock 第三方库存信息
     * @return 结果
     */
    @Override
    public int insertT3rdstock(T3rdstock t3rdstock)
    {
        t3rdstock.setCreateTime(DateUtils.getNowDate());
        return t3rdstockMapper.insertT3rdstock(t3rdstock);
    }

    /**
     * 修改第三方库存信息
     * 
     * @param t3rdstock 第三方库存信息
     * @return 结果
     */
    @Override
    public int updateT3rdstock(T3rdstock t3rdstock)
    {
        t3rdstock.setUpdateTime(DateUtils.getNowDate());
        return t3rdstockMapper.updateT3rdstock(t3rdstock);
    }

    /**
     * 增加第三方库存
     *
     * @param t3rdstock 第三方库存信息
     * @return 结果
     */
    @Override
    public int updateT3rdstockByAdd(T3rdstock t3rdstock)
    {
        if (selectT3rdstockByGoodIdAndWarehouseId(t3rdstock).isEmpty()) {
            int res = insertT3rdstock(t3rdstock);
            return res;
        }
        t3rdstock.setUpdateTime(DateUtils.getNowDate());
        return t3rdstockMapper.updateT3rdstockByAdd(t3rdstock);
    }

    /**
     * 批量删除第三方库存信息
     * 
     * @param warehouseIds 需要删除的第三方库存信息主键
     * @return 结果
     */
    @Override
    public int deleteT3rdstockByWarehouseIds(String[] warehouseIds)
    {
        return t3rdstockMapper.deleteT3rdstockByWarehouseIds(warehouseIds);
    }

    /**
     * 删除第三方库存信息信息
     * 
     * @param warehouseId 第三方库存信息主键
     * @return 结果
     */
    @Override
    public int deleteT3rdstockByWarehouseId(String warehouseId)
    {
        return t3rdstockMapper.deleteT3rdstockByWarehouseId(warehouseId);
    }
}
